<template>
  <div class="app-container">
    <!-- 搜索区域 -->
    <div class="search-container" >
      <el-form ref="queryFormRef" :model="queryParams" :inline="true" >
        <el-form-item label="账号" prop="keywords">
          <el-input
            v-model="queryParams.keywords"
            placeholder="账号名称"
            @keyup.enter="handleQuery"
          />
        </el-form-item>

        <el-form-item label="邀请码" prop="inviteCode">
          <el-input
            v-model="queryParams.inviteCode"
            placeholder="邀请码"
            @keyup.enter="handleQuery"
          />
        </el-form-item>

        <!-- <el-form-item label="ID" prop="id">
          <el-input
            v-model="queryParams.id"
            placeholder="账号ID"
            @keyup.enter="handleQuery"
          />
        </el-form-item> -->

        <el-form-item label="会员等级" prop="level_status">
          <el-select
            v-model="queryParams.level_status"
            placeholder="全部"
            clearable
            style="width: 150px"
          >
          
            <el-option v-for="(item,index) in levelArr" :key="index" :label="item.adName" :value="item.id" />
          
          </el-select>
        </el-form-item>

        <el-form-item label="状态" prop="status">
          <el-select
            v-model="queryParams.status"
            placeholder="全部"
            clearable
            style="width: 150px"
          >
            <el-option label="正常" :value="1" />
            <el-option label="已注销" :value="2" />
            <el-option label="已冻结" :value="3" />

          </el-select>
        </el-form-item>

        <el-form-item label="类型" prop="accType">
          <el-select
            v-model="queryParams.accType"
            placeholder="全部"
            clearable
            style="width: 150px"
          >
            <el-option label="注册用户" :value="1" />
            <el-option label="会员" :value="2" />

          </el-select>
        </el-form-item>

        <el-form-item label="波场地址" prop="queryParams.tronAddress">
          <el-input
            v-model="queryParams.tronAddress"
            placeholder="请输入波场地址"
            @keyup.enter="handleQuery"
          />
        </el-form-item>

        <el-form-item label="币安地址" prop="queryParams.bnbAddress">
          <el-input
            v-model="queryParams.bnbAddress"
            placeholder="请输入币安地址"
            @keyup.enter="handleQuery"
          />
        </el-form-item>



        <!-- <el-form-item label="创建时间">
              <el-date-picker
                v-model="queryParams.createTime"
                :editable="false"
                type="daterange"
                range-separator="~"
                start-placeholder="开始时间"
                end-placeholder="截止时间"
                value-format="YYYY-MM-DD"
              />
            </el-form-item> -->
        
        

        <el-form-item class="search-buttons">
          <el-button class="filter-item" type="primary" icon="search" @click="handleQuery">
            搜索
          </el-button>
          <el-button icon="refresh" @click="handleResetQuery">重置</el-button>


          <el-button @click="daochu()">导出钱包信息</el-button>

          <!-- <el-button icon="info" style="margin-left: 150px;">注册人数:0人</el-button>
          <el-button icon="info">广告商数量:0人</el-button> -->

        </el-form-item>
      </el-form>
    </div>

    <el-card shadow="hover" class="data-table">
      <el-table
          v-loading="loading"
          :data="Lists"
          row-key="id"
          default-expand-all
          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
          class="data-table__content"
          @selection-change="handleSelectionChange"
        >
        <el-table-column type="selection" width="55" align="center" />

        <el-table-column prop="id" label="Id" width="80" />

        <el-table-column prop="account" label="账号" />
        <el-table-column prop="markId" label="邀请码" />
        <el-table-column prop="userLevelId" label="等级" />

        <el-table-column prop="nickname" label="昵称" />

        <el-table-column prop="headImg" label="头像" >
          <template #default="{ row }">
            <el-image
              style="width: 50px; height: 50px; border-radius: 50%"
              :src="row.headImg || 'https://xcx.yumeishangmao.com/uploads/8b112625e64da7e7dc69fab1044487e5.png'"
              :preview-src-list="[row.headImg]"
            />
          </template>
        </el-table-column>

        <el-table-column prop="email" label="邮箱" />

        <el-table-column label="是否办过会员" align="center" prop="accType" >
          <template #default="scope">
            <el-tag :type="scope.row.accType != '1' ? 'success' : 'info'">
              {{ scope.row.accType != '1' ? "是" : "否" }}
            </el-tag>
          </template>
        </el-table-column>

        <el-table-column prop="userWallet.points" label="积分"  />

        <el-table-column prop="userWallet.uBalance" label="余额"  />
        <el-table-column prop="userWallet.tronAddress" label="波场地址"  />
        <el-table-column prop="userWallet.bnbAddress" label="币安地址"  />



        <el-table-column label="状态" align="center" prop="accState">
          <template #default="scope">
              <div v-if="scope.row.accState=='1'">正常</div>
              <div v-else-if="scope.row.accState=='2'">注销</div>
              <div v-else-if="scope.row.accState=='3'">冻结</div>
              <div v-else>未知</div>
          </template>
        </el-table-column>

        <el-table-column prop="createTime" label="创建时间" width="200" />

        <el-table-column label="操作" fixed="right" align="left"  width="120" >
          <template #default="scope" >
            
            <el-button
v-if="scope.row.accState == '3'"
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog(scope.row.id,scope.row,1)"
            >
              恢复
            </el-button>

            <el-button
v-if="scope.row.accState == '1'"
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog(scope.row.id,scope.row,3)"
            >
              冻结            
            </el-button> 


            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog1(scope.row.markId,scope.row)"
            >
              修改usdt            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog2(scope.row.markId,scope.row)"
            >
              修改积分            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog22(scope.row.markId,scope.row)"
            >
              修改密保            
            </el-button>
            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleUpdateWalletAddress(scope.row.markId,scope.row)"
            >
              修改钱包地址            
            </el-button>
        </template>
      </el-table-column>
      <el-table-column label="查看" fixed="right" align="left" width="120">
        <template #default="scope" >
            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog3(scope.row.markId,scope.row,'up')"
            >
              查看上级            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="handleOpenDialog3(scope.row.markId,scope.row,'down')"
            >
              查看下级            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="score_record(scope.row)"
            >
              积分记录            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="usdt_record(scope.row)"
            >
              USDT记录            
            </el-button>

             <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="charge_record(scope.row)"
            >
              充值记录            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="ad_level(scope.row)"
            >
              广告商等级            
            </el-button>

            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="secret_key(scope.row)"
            >
              查看钱包密钥            
            </el-button>


            <el-button
              type="primary"
              link
              size="small"
              icon="edit"
              @click.stop="Member_performance(scope.row)"
            >
              查看团队业绩            
            </el-button>

            
            
          </template>
        </el-table-column>


      </el-table>

      <pagination
            v-if="total > 0"
            v-model:total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="handleQuery"
          />


            <el-dialog
              v-model="dialog.visible"
              :title="dialog.title"
              width="600px"
              @closed="handleCloseDialog"
            >
              <el-form ref="FormRef" :model="formData" :rules="rules" label-width="120px">
                
                <el-form-item label="状态" >
                  <el-radio-group v-model="dialog_status">
                    <el-radio v-if="dialog_status==1" :value="1">正常</el-radio>
                    <el-radio v-if="dialog_status==3" :value="3">冻结</el-radio>
                  </el-radio-group>
                </el-form-item>

                <block v-if="dialog_status==3">
                    <el-form-item label="冻结原因" >
                      <el-input v-model="formData.reason" placeholder="请输入冻结原因" />
                    </el-form-item>
                </block>
              </el-form>

              <template #footer>
                <div class="dialog-footer">
                  <el-button type="primary" @click="handleSubmit">确 定</el-button>
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>
            </el-dialog>

             <el-dialog
              v-model="dialog22.visible"
              :title="'修改密保'"
              width="600px"
              @closed="handleCloseDialog"
            >
              <el-form ref="FormRef1" :model="memberData" :rules="rules" label-width="120px">

                <el-form-item label="密保答案" >
                  <el-input v-model="memberData.answer" type="number" maxlength="8" placeholder="请输入密保答案" @input="handleInput" />
                </el-form-item>

              
              </el-form>

              <template #footer>
                <div class="dialog-footer">
                  <el-button type="primary" @click="handleSubmit22">确 定</el-button>
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>
            </el-dialog>


            <el-dialog
              v-model="dialog1.visible"
              :title="'修改USDT'"
              width="600px"
              @closed="handleCloseDialog"
            >
              <el-form ref="FormRef1" :model="memberData" :rules="rules" label-width="120px">
                <div style="padding-left: 15px;"> 当前USDT:{{ memberData.uBalance }}</div>
                <br>

                <el-form-item label="操作USDT" >
                  <el-input v-model="memberData.amount" placeholder="请输入USDT" />
                </el-form-item>

                <el-form-item label="操作类型" >
                  <el-radio-group v-model="memberData.usdtType">
                    <el-radio :value="1">充值</el-radio>
                    <el-radio :value="2">扣除</el-radio>
                    <el-radio :value="3">奖励</el-radio>
                  </el-radio-group>
                </el-form-item>

              </el-form>

              <template #footer>
                <div class="dialog-footer">
                  <el-button type="primary" @click="handleSubmit1">确 定</el-button>
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>
            </el-dialog>


            <el-dialog
              v-model="dialog2.visible"
              :title="'修改积分'"
              width="600px"
              @closed="handleCloseDialog"
            >
              <el-form ref="FormRef1" :model="memberData" :rules="rules" label-width="120px">
                <div style="padding-left: 15px;"> 当前积分:{{ memberData.points }}</div>
                <br>

                <el-form-item label="操作积分" >
                  <el-input v-model="memberData.score" placeholder="请输入积分" />
                </el-form-item>

                <el-form-item label="操作类型" >
                  <el-radio-group v-model="memberData.operateType">
                    <el-radio :value="1">增加</el-radio>
                    <el-radio :value="2">减少</el-radio>
                  </el-radio-group>
                </el-form-item>

              </el-form>

              <template #footer>
                <div class="dialog-footer">
                  <el-button type="primary" @click="handleSubmit2">确 定</el-button>
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>
            </el-dialog>
    
            <el-dialog
              v-model="dialog3.visible"
              :title="dialog3.visible ? dialog3.title : ''"
              width="600px"
              @closed="handleCloseDialog"
            >
              <el-table
                v-loading="loading"
                :data="queryList"
                row-key="id"
                class="data-table__content"
              >
                <!-- <el-table-column prop="id" label="用户ID" width="80" /> -->
                <el-table-column prop="account" label="账号" />
                <el-table-column prop="nickname" label="昵称" />
                <el-table-column prop="markId" label="邀请码" />
              </el-table>

              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>
            </el-dialog>



            <el-dialog
              v-model="dialog4.visible"
              :title="'积分记录'"
              width="80%"
              @closed="handleCloseDialog"
            >
              <score_record_list
              v-if="dialog4.visible"
                :id="score_query_id"
                :account="score_query_account"
              />  
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>

            </el-dialog>
    
             <el-dialog
              v-model="dialog5.visible"
              :title="'USDT记录'"
              width="80%"
              @closed="handleCloseDialog"
            >
              <usdt_record_list
v-if="dialog5.visible"
                :id="usdt_query_id"
                :account="usdt_query_account"
              />  
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>

            </el-dialog>

            <el-dialog
              v-model="dialog6.visible"
              :title="'充值记录'"
              width="80%"
              @closed="handleCloseDialog"
            >
              <charge_list
v-if="dialog6.visible"
                :id="charge_query_id"
                :account="charge_query_account"
              />  
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>

            </el-dialog>


            <el-dialog
              v-model="dialog7.visible"
              :title="'广告商等级'"
              width="80%"
              @closed="handleCloseDialog"
            >
              <level_list
                v-if="dialog7.visible"
                :id="ad_level_query_id"
              />  
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">取 消</el-button>
                </div>
              </template>

            </el-dialog>


            <el-dialog
              v-model="dialog8.visible"
              :title="'钱包密钥'"
              width="600px"
              @closed="handleCloseDialog"
            >
              <el-form ref="FormRef1" :model="memberData" :rules="rules" label-width="120px">
                <div style="padding-left: 15px;"> <b>bnbKey : </b>{{ memberData.bnbKey }}</div>
                <div style="padding-left: 15px;"> <b>tronKey : </b>{{ memberData.tronKey }}</div>
              </el-form>

              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">关 闭</el-button>
                </div>
              </template>
            </el-dialog>

            <el-dialog
              v-model="dialog9.visible"
              :title="'团队业绩'"
              width="600px"
              @closed="handleCloseDialog"
            >

              <el-form ref="FormRef1" :model="memberData" :rules="rules" label-width="120px">
                <div style="padding-left: 15px;"> <b>总业绩 : </b>{{ memberData.total_fee }}</div>
                <div style="padding-left: 15px;"> <b>昨日业绩 : </b>{{ memberData.yesterday_fee }}</div>
              </el-form>

              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="handleCloseDialog">关 闭</el-button>
                </div>
              </template>
            </el-dialog>

    </el-card>

  </div>
</template>

<script setup lang="ts">
defineOptions({
  name: "会员",
  inheritAttrs: false,
});

import MemberAPI, { MemberVO } from "@/api/system/member.api";
import score_record_list from "./components/score_record.vue";
import usdt_record_list from "./components/usdt_record.vue";
import charge_list from "./components/charge.vue";
import level_list from "./components/level_list.vue";

const levelArr = ref();

// MemberAPI.getLevelList().then((res) => {
//   console.log("会员等级列表:", res);
//   levelArr.value = res;
// });
levelArr.value = [
  {
    id: 1,
    adName: "一级",
  },
  {
    id: 2,
    adName: "二级",
  },
  {
    id: 3,
    adName: "三级",
  },
  {
    id: 4,
    adName: "四级",
  },
  {
    id: 5,
    adName: "五级",
  },
  {
    id: 6,
    adName: "六级",
  },
  {
    id:7,
    adName:"七级"
  }
];


const queryFormRef = ref();
const FormRef = ref();
const FormRef1 = ref();

const rules = reactive({
  status: [{ required: true, message: "请选择状态", trigger: "change" }],
});

const loading = ref(false);
const selectIds = ref<number[]>([]);
const queryParams = reactive<any>({
  pageNum: 1,
  pageSize: 10,
});

const Lists = ref<MemberVO[]>();
const total = ref(0);

// 查询
function handleQuery() {
  console.log(queryParams)
  loading.value = true;
  
  MemberAPI.getList(queryParams)
  .then((res) => {
    Lists.value = res.data;
    total.value = res.total;
  })
  .catch((error) => {
    console.error("查询失败:", error);
  })
  .finally(() => {
    loading.value = false;
  });
  loading.value = false;
}

function handleInput() {
  memberData.answer = memberData.answer.replace(/\D/g, '').slice(0, 8)
}

// 重置查询
function handleResetQuery() {
  queryFormRef.value.resetFields();
  handleQuery();
}

// 处理选中项变化
function handleSelectionChange(selection: any) {
  selectIds.value = selection.map((item: any) => item.id);
}

const score_query_id = ref();
const score_query_account = ref();
const dialog4 = reactive({
  title: "积分记录",
  visible: false,
});

function score_record(row: MemberVO) {
  score_query_id.value = row.id;
  score_query_account.value = row.account;
  dialog4.visible = true; 
}


const usdt_query_id = ref();
const usdt_query_account = ref();
const dialog5 = reactive({
  title: "usdt记录",
  visible: false,
});


function usdt_record(row: MemberVO) {
  usdt_query_id.value = row.id;
  usdt_query_account.value = row.account;
  dialog5.visible = true;
}


const charge_query_id = ref();
const charge_query_account = ref();
const dialog6 = reactive({
  title: "充值记录",
  visible: false,
});

function charge_record(row: MemberVO) {
  charge_query_id.value = row.id;
  charge_query_account.value = row.account;
  dialog6.visible = true;
}

const ad_level_query_id = ref();
const dialog7 = reactive({
  title: "广告商等级",
  visible: false,
});
function ad_level(row: MemberVO) {
  ad_level_query_id.value = row.id;
  dialog7.visible = true;
}


const dialog8 = reactive({
  title: "钱包密钥",
  visible: false,
});
function secret_key(row: MemberVO) {
  MemberAPI.Member_cipher_key_URL({ userId: row.id })
    .then((res) => {
      console.log("查询信息成功:", res);
      memberData.tronKey = res.tronKey;
      memberData.bnbKey = res.bnbKey;
      dialog8.visible = true;
    })
    .catch((error) => {
      console.error("查询信息失败:", error);
      dialog8.visible = true;
    });

}

const dialog9 = reactive({
  title: "团队业绩",
  visible: false,
});
function Member_performance(row: MemberVO) {
  MemberAPI.Member_performance_URL({ userId: row.id })
    .then((res) => {
      console.log("查询信息成功:", res);
      memberData.total_fee = res.userPerf.total_fee;
      memberData.yesterday_fee = res.userPerf.yesterday_fee;
      dialog9.visible = true;
    })
    .catch((error) => {
      console.error("查询信息失败:", error);
      dialog9.visible = true;
    });

}


const dialog = reactive({
  title: "",
  visible: false,
});
const dialog1 = reactive({
  title: "",
  visible: false,
});
const dialog2 = reactive({
  title: "",
  visible: false,
});
const dialog22 = reactive({
  title: "",
  visible: false,
});
const dialog3 = reactive({
  title: "上级信息",
  visible: false,
});
const updateWalletAddressDialog = reactive({
  title: '更新钱包地址',
  visible: false,
});


const memberData = reactive<any>({
  score: 0,
  markId: "",
  operateType: 1, // 默认增加
});


const formData = reactive<any>({
  auditTime: "",
  id: undefined,
  status: 1,
  reason: "",
});
const dialog_status = ref<number>(1);
const dialog_markId = ref();


/**
 * 打开操作弹窗
 *
 * @param Id ID
 */
async function handleOpenDialog(Id?:string,data?:MemberVO,status?: number) {

  dialog.visible = true;
  if (Id) {
    dialog.title = "编辑";
    dialog_status.value = status || 1
    if(data&&status){
      dialog_markId.value = data.markId||'';
      data.status = status || 1;
    }
    Object.assign(formData, data);
  } else {
    dialog.title = "编辑";
    dialog_status.value = status || 1;
  }
}

const memberId = ref();

async function handleOpenDialog1(Id?:string,data?:any) {
  dialog1.visible = true;
  memberId.value = Id;
  if (Id) {
    dialog1.title = "修改USDT";
    memberData.markId = Id;
    memberData.uBalance = data.userWallet.uBalance || 0; // 确保USDT有值
    memberData.usdtType = 1; // 默认增加
  } else {
    dialog1.title = "新增";
  }
  memberData.amount = 0;
}

async function handleOpenDialog2(Id?:string,data?:any) {
  dialog2.visible = true;
  memberId.value = Id;
  if (Id) {
    dialog2.title = "修改积分";
    memberData.markId = Id;
    memberData.points = data.userWallet.points || 0; // 确保积分有值
    memberData.operateType = 1; // 默认增加
  } else {
    dialog2.title = "新增";
  }
  memberData.score = 0; 
}

async function handleOpenDialog22(Id?:string,data?:any) {
  dialog22.visible = true;
  memberId.value = Id;
  if (Id) {
    dialog22.title = "修改密保";
    memberData.markId = Id;
  } else {
    dialog22.title = "新增";
  }
  memberData.answer = data.answer || '';
  memberData.userId = data.id || '';
}

const queryList = ref();
async function handleOpenDialog3(Id?:string,data?:any,type?:string) {
  dialog3.visible = true;
  memberId.value = Id;
  if (Id) {
    let json = {
      userId: data.id,
      queryType:2
    }
    if(type=='down'){
      dialog3.title = "查看下级";
      json = {
        userId: data.id,
        queryType:1
      };
    }else{
      dialog3.title = "查看上级";
      json = {
        userId: data.id,
        queryType:2
      };
    }
    
    
    MemberAPI.Member_relation_URL(json)
      .then((res) => {
        queryList.value = res;
      })
      .catch((error) => {
        console.error("查询信息失败:", error);
      });

  } 
}

function handleUpdateWalletAddress(id: number, data: any, type?: string) {
  // 这里可以根据需要实现更新钱包地址的逻辑
  console.log(`更新用户ID为 ${id} 的 ${type} 地址`, data);
  updateWalletAddressDialog.visible = true;
}


// 提交表单
function handleSubmit() {
  FormRef.value.validate((valid: any) => {
    if (valid) {
      loading.value = true;
      const dataJson = {
        "markId": dialog_markId.value, //ID
        "acState": dialog_status.value, //状态
        "reason": formData.reason //冻结原因
      };
      MemberAPI.Member_state_URL(dataJson)
        .then(() => {
          ElMessage.success("修改成功");
          handleCloseDialog();
          handleQuery();
        })
        .finally(() => (loading.value = false));
    }
  });
}

function handleSubmit1() {
  
  loading.value = true;

  const json = {
    markId: memberId.value,
    operateType:memberData.usdtType,
    amount_u: parseInt(memberData.amount), // 确保USDT有值
  }
  MemberAPI.updateUsdt(json)
    .then(() => {
      ElMessage.success("修改成功");
      handleCloseDialog();
      handleQuery();
    })
    .finally(() => (loading.value = false));
}


function handleSubmit2() {
  
  loading.value = true;

  const json = {
    markId: memberId.value,
    operateType:memberData.operateType,
    points: parseInt(memberData.score), // 确保积分有值
  }
  MemberAPI.updateScore(json)
    .then(() => {
      ElMessage.success("修改成功");
      handleCloseDialog();
      handleQuery();
    })
    .finally(() => (loading.value = false));
}

function handleSubmit22() {
  
  loading.value = true;

  const json = {
    "userId": memberData.userId, //用户ID(用户列表获得)
    "answer": memberData.answer //密保答案
  }
  MemberAPI.updateAnswer(json)
    .then(() => {
      ElMessage.success("修改成功");
      handleCloseDialog();
      handleQuery();
    })
    .finally(() => (loading.value = false));
}



// 重置表单
function resetForm() {
  // FormRef.value.resetFields();
  // FormRef.value.clearValidate();
  // FormRef1.value.resetFields();
  // FormRef1.value.clearValidate();
}

// 关闭弹窗
function handleCloseDialog() {
  dialog.visible = false;
  dialog1.visible = false;
  dialog2.visible = false;
  dialog22.visible = false;
  dialog3.visible = false;
  dialog4.visible = false;
  dialog5.visible = false;
  dialog6.visible = false;
  dialog7.visible = false;
  dialog8.visible = false;
  dialog9.visible = false;

  resetForm();
}

function daochu(){
  MemberAPI.Member_export_wallet_key_URL().then((res) => {
    // 确保字符串以UTF-8 BOM开头，解决Excel中文乱码问题
    const BOM = '\uFEFF';
    const content = BOM + res;
    
    // 创建Blob对象
    const blob = new Blob([content], { type: 'text/csv;charset=utf-8;' });
    
    // 创建下载链接
    const link = document.createElement('a');
    const url = URL.createObjectURL(blob);
    const filename = `钱包信息_${new Date().toISOString().slice(0, 10)}`;

    link.href = url;
    link.download = `${filename}.csv`;
    link.style.visibility = 'hidden';
    
    // 触发下载
    document.body.appendChild(link);
    link.click();
    
    // 清理
    document.body.removeChild(link);
    URL.revokeObjectURL(url);


  }).catch((error) => {
    console.error("导出失败:", error);
  });
}


onMounted(() => {
  handleQuery();
});
</script>
